Overview:

This tool detects dimensional anomalies in civil engineering model data using unsupervised machine learning (Isolation Forest and K-Means clustering). It is designed as a standalone desktop application with a simple graphical interface.

This tool was developed in Python using Scikit-learn, Tkinter, Pandas, NumPy, and Matplotlib.

Files Included:
1. User_Interface.py
   - The main application script. Launches a GUI where users can load data, run models, and view results.

2. convert_json_to_csv.py
   - A helper script that converts Bentley-style iTwin JSON data into a compatible CSV format.

3. simulated_itwin_model.json
   - Sample input data representing simulated component geometry exported from a digital twin.

4. Dimension_Data_From_iTwin.csv
   - A pre-converted CSV file from the JSON above, ready for use in the main app.

How to Run:
1. Ensure Python 3.11+ is installed with the following libraries:
   - pandas
   - numpy
   - matplotlib
   - scikit-learn
   - tkinter (usually included with Python)

2. Open a terminal or command prompt.

3. To convert JSON to CSV:
   > python convert_json_to_csv.py

4. To launch the GUI:
   > python User_Interface.py

Using the App:
1. Load CSV:
   - Click "Load CSV File" and select `Dimension_Data_From_iTwin.csv` or your own formatted file.

2. Select a Model:
   - Use the dropdown to choose between "Isolation Forest" and "K-Means".

3. Run Detection:
   - Click "Run Anomaly Detection" to identify and label dimensional outliers.

4. Filter and View Results:
   - Use the filter dropdown to view specific component types.
   - The anomaly table will update accordingly.

5. View Chart:
   - Click "Show Chart" to see a scatter plot of anomalies (Length vs Height).

6. View Metrics:
   - Click "Show Evaluation Metrics" to see precision, recall, and F1-score by model and element type.

Input File Format:
The CSV must contain the following headers:
- id
- type
- Length (mm)
- Width (mm)
- Height (mm)

All dimensions must be numeric.

Support & Notes:
- This is a prototype tool developed for academic use as part of a civil engineering dissertation.
- Model performance is based on synthetic testing data and may need adaptation for real project datasets.
- This tool was created collaboratively by the author and supporting software engineers at ARUP.

